#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

using std::vector;
using std::cin;
using std::cout;

long long din(int n, int m, vector<vector<long long> > &dinamic, vector<vector<long long> > &a) {
    if(n < 0 || m < 0) {
        return 0;
    }
    if (dinamic[n][m] + 1) {
        return dinamic[n][m];
    }
    dinamic[n][m] = (a[n][m] * (din(n-1, m, dinamic, a) + din(n, m-1, dinamic, a))) % 268435459;
    return dinamic[n][m];
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<long long> > a(n), dinamic(n);
    for (int i = 0; i < n; ++i) {
            a[i].resize(m);
        dinamic[i].resize(m, -1);
        for (int j = 0; j < m; ++j) {
            cin >> a[i][j];
        }
    }
    dinamic[0][0] = a[0][0];
    cout << din(n-1, m-1, dinamic, a);
    return 0;
}